package others;

import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Time {

	public static String timeCompress(String startTimeStamp, String currentTimeStamp, int originTimeLength, int newTimeLength) throws ParseException{
		String newTimeStamp = "";
    
		int proportion = originTimeLength/newTimeLength;
		
	    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");  
	    java.util.Date date1 = format.parse("2002-02-28 23:16:00");  
	    //long Time=(date1.getTime()/1000)+60*30;  
	    //date1.setTime(Time*1000);  
	    
	    java.util.Date newDate=new java.util.Date();
	    java.util.Date startDate = format.parse(startTimeStamp);
	    java.util.Date currentDate = format.parse(currentTimeStamp);
	    
	    Long startTime = startDate.getTime();
	    Long currentTime = currentDate.getTime();	      
	    Long newTime = (currentTime - startTime)/proportion + startTime;
	    
	    newDate.setTime(newTime);
	    
	    newTimeStamp = format.format(newDate);
	    System.out.println(newTimeStamp);  
	    
		return newTimeStamp;
	}
	
	public static void main(String[] args) throws Exception {
		String timeString = timeCompress("2002-02-28 23:16:00","2002-02-28 23:16:10", 24,3);
		System.out.println("新时间是："+ timeString);  
	}
}
